package com.simblog.oaknt.service.impl;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import com.simblog.oaknt.domain.Article;
import com.simblog.oaknt.mapper.ArticleMapper;
import com.simblog.oaknt.service.IArticleService;

//@Service(interfaceClass=IArticleService.class, timeout=30000,cache="true")
@Service
public class ArticleServiceImpl extends BaseServiceImpl<Article> implements IArticleService{
	
	private final static Logger log= Logger.getLogger(ArticleServiceImpl.class);
	
	@Autowired
    private ArticleMapper mapper;

		
	public ArticleMapper getMapper() {
		return mapper;
	}

	@Cacheable(value="MyCache",key="'category_count='+#params.get('userId')")
	public List<Map<String, Object>> countByCategory(Map<String, Object> params) {
		log.info("从数据库查找用户id={" + params.get("userId") + "}，统计文章类别对应的文章数量");
		return mapper.countByCategory(params);
	}

	@Cacheable(value="MyCache",key="'time_count='+#params.get('userId')")
	public List<Map<String, Object>> countByTime(Map<String, Object> params) {
		log.info("从数据库查找用户id={" + params.get("userId") + "}，统计发布时间对应的文章数量");
		return mapper.countByTime(params);
	}

	@Override
	public List<Article> queryDetail(Map<String, Object> params) {
		return mapper.queryDetail(params);
	}

}
